import request from '@/utils/request';

export async function getPurchaseOrderByPage(params: any) {
  return request('/api/material/getPurchaseOrderByPage', {
    method: 'POST',
    data: params,
  });
}

//获取订单 + 对应的订单行
export async function getPurchaseOrderTotalByPage(params: any){
  return request('/api/material/getPurchaseOrderTotalByPage',{
    method:'POST',
    data: params,
  })
}

export async function addPurchaseOrder(params: any) {
  return request('/api/material/addPurchaseOrder', {
    method: 'POST',
    data: params,
  });
}

export async function updatePurchaseOrder(params: any) {
  return request('/api/material/updatePurchaseOrder', {
    method: 'POST',
    data: params,
  });
}

export async function delPurchaseOrder(params: any) {
  return request('/api/material/delPurchaseOrder', {
    method: 'POST',
    data: params,
  });
}

//新增物料/api/material/addPurchaseOrderDetail
export async function addPurchaseOrderDetail(params: any) {
  return request('/api/material/addPurchaseOrderDetail', {
    method: 'POST',
    data: params,
  });
}

export async function exportPurchaseOrder(params: any) {
  return request('/api/material/exportPurchaseOrder', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

//采购订单同步
export async function purchaseOrderInfoSync() {
  return request('/api/purchaseOrderInfo/sync', {
    method: 'POST',
  });
}

export default {
  getPurchaseOrderByPage,
  addPurchaseOrder,
  updatePurchaseOrder,
  delPurchaseOrder,
  exportPurchaseOrder,
};
